from app import db
from .base_model import BaseModel


class BlogUser(BaseModel):
    '''用户'''
    __tablename__ = 'blog_user'
    __table_args__ = ({'comment': '系统用户'})
    id = db.Column(db.Integer, primary_key=True, comment="用户ID")
    username = db.Column(db.String(255),
                         nullable=False,
                         unique=True,
                         comment="用户名")
    password = db.Column(db.String(320), nullable=False, comment="密码")
    avatar = db.Column(db.String(255), nullable=True, comment="头像")
    super_user = db.Column(db.Boolean,
                           nullable=True,
                           default=False,
                           comment="超级用户")
    active_user = db.Column(db.Boolean,
                            nullable=True,
                            default=True,
                            comment="活跃用户")
    staff_user = db.Column(db.Boolean,
                           nullable=True,
                           default=False,
                           comment="后台管理")

    def __repr__(self) -> str:
        return '<BlogUser %r>' % self.to_json()
